package logic

import (
	"context"
	"doc-manage/models/mysql"
	"errors"

	"doc-manage/doctorrpc/doctorrpc"
	"doc-manage/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DoctorShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDoctorShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DoctorShowLogic {
	return &DoctorShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情方法
func (l *DoctorShowLogic) DoctorShow(in *doctorrpc.DoctorShowRequest) (*doctorrpc.DoctorShowResponse, error) {
	// todo: add your logic here and delete this line

	var doctor mysql.Doctor

	err := doctor.DoctorShow(mysql.DB, in.DoctorId)
	if err != nil {
		return nil, errors.New("详情失败")
	}

	return &doctorrpc.DoctorShowResponse{
		DoctorId:    int64(doctor.ID),
		DoctorName:  doctor.DoctorName,
		DoctorImage: doctor.DoctorImage,
	}, nil
}
